import {messages} from "share/common";
import React from 'react'
import { connect } from 'react-redux'
import {Radio, Alert } from 'antd'
import SubApplication from 'containers/setting/sub-application/sub-application-management/sub-application';
import ModuleDisplaySetting from 'containers/setting/sub-application/module-display-setting/module-display-setting'
let component = {
  "application": <SubApplication/>,
  "display": <ModuleDisplaySetting/>
};

class SubApplicationIndex extends React.Component{
  constructor(props) {
    super(props);
    this.state = {
      mode: 'application',
    }
  }

  componentDidMount() {
  }

  handleModeChange = (e) => {
    this.setState({
      mode: e.target.value
    });
  };

  render() {
    const {mode} = this.state;
    return (
      <div>
        <div style={{marginBottom: 20}}>
          <Alert message={messages('setting.key1781')/*设置后将同时对APP/微信/钉钉端生效*/} type="info" showIcon />
        </div>
        <Radio.Group onChange={this.handleModeChange} value={mode} style={{ marginBottom: 8 }}>
          <Radio.Button value="application">{messages('setting.key1617')/*App应用设置*/}</Radio.Button>
          <Radio.Button value="display">{messages('setting.key1618')/*模块显示设置*/}</Radio.Button>
        </Radio.Group>
        <div>
          {component[mode]}
        </div>
      </div>
    )
  }
}

SubApplicationIndex.contextTypes ={
  router: React.PropTypes.object
};

function mapStateToProps(state) {
  return {
    language: state.main.language,
  }
}

export default connect(mapStateToProps)(SubApplicationIndex)
